package com.tencent.wxcloudrun.config;

import cn.hutool.core.util.StrUtil;
import com.tencent.wxcloudrun.dto.RepaymentInfo;
import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.Map;

/**
 * ConstantsConfig
 * 配置
 *
 **/
public class ConstantsConfig {

    public static final Map<String, RepaymentInfo> REPAYMENT_MAP = new HashMap<>(3);

    static {
        // 初始化常量（商品+周期：明细）
        REPAYMENT_MAP.put("10000_12", new RepaymentInfo(913, 540, 1453));
        REPAYMENT_MAP.put("10000_8", new RepaymentInfo(1180, 670, 1850));
        REPAYMENT_MAP.put("10000_4", new RepaymentInfo(2330, 770, 3100));

        REPAYMENT_MAP.put("15000_12", new RepaymentInfo(1330, 785, 2215));
        REPAYMENT_MAP.put("15000_8", new RepaymentInfo(1955, 785, 2740));
        REPAYMENT_MAP.put("15000_4", new RepaymentInfo(3830, 785, 4615));

        REPAYMENT_MAP.put("20000_12", new RepaymentInfo(1826, 1080, 2906));
        REPAYMENT_MAP.put("20000_8", new RepaymentInfo(2360, 1340, 3700));
        REPAYMENT_MAP.put("20000_4", new RepaymentInfo(4660, 1540, 6200));

    }


    /**
     *
     * @param amount 总额
     * @param weekNum 周期
     */
    @Nullable
    public static RepaymentInfo getRepaymentInfo(Integer amount, Integer weekNum) {
        String key = StrUtil.format("{}_{}", amount, weekNum);
        return REPAYMENT_MAP.get(key);
    }
}
